package com.exercise.v2;

public abstract class AbstractExpression {
    protected int operand1;
    protected int operand2;

    public AbstractExpression() {
        this.operand1 = 0;
        this.operand2 = 0;
    }
    public AbstractExpression(int operand1, int operand2) {
        this.operand1 = operand1;
        this.operand2 = operand2;
    }

    public abstract int calculate();

    public abstract String getOperator();

    public int getOperand1() {
        return operand1;
    }

    public void setOperand1(int operand1) {
        this.operand1 = operand1;
    }

    public int getOperand2() {
        return operand2;
    }

    public void setOperand2(int operand2) {
        this.operand2 = operand2;
    }

    public int getResult() {
        return calculate();
    }

    public String toString() {
        return operand1 + " " + getOperator() + " " + operand2 + " = " + calculate();
    }

    public String toQuestionString() {
        return operand1 + " " + getOperator() + " " + operand2 + " = ?";
    }
}

